<?php

class ajkeywordAction extends Action
{

    public function _init()
    {
        $this->assign('action', $_GET['TMAC_ACTION']);
        $this->tmp_model = Tmac::model('index');
        $this->common_model = Tmac::model('common');
        $this->index_model = Tmac::model('index');
    }

    public function index()
    {
        $cityid = !empty($_GET['id']) ? $_GET['id'] : 0;
        $rs = '<h5>';
        //设置首页默认第一的搜索城市 $uncityinfo
        $uncityinfo_array = $this->tmp_model->setDefaultCity(0);
        foreach ($uncityinfo_array AS $k => $v) {
            $rs .= "<a href=\"javascript:loadWord({$v['cityid']},'{$v['cityname']}');\" class='search_h5_marright'>";
            if ($cityid == $v['cityid']) {
                $rs .= "<B>{$v['cityname']}</B>";
            } else {
                $rs .= "{$v['cityname']}";
            }
            $rs .= "</a>　";
        }
        $rs .= '</h5>';
        $rs .= '<ul>';
        //取城市地标
        $citylable_array = $this->tmp_model->citylable($cityid, 12);
        $rs .= $citylable_array[0];
        foreach ($citylable_array[1] AS $k => $v) {
            $rs .= "<li><a href='index.php?m=hotellist&cityid={$v['cityid']}&rank=0&key=";
            $rs .= urlencode($v['key']);
            $rs .= "' title='{$v['key']}' target='_blank'>{$v['key']}</a></li>";
        }
        $rs .= "</ul>";
        echo $rs;
        Functions::replace_for_mod_rewrite();
    }

    public function tuijian()
    {
        $cityid = !empty($_POST['cid']) ? $_POST['cid'] : 0;
        $picurl = $GLOBALS['TmacConfig']['config']['picurl'];
        //取cityinfo
        $globals_model = Tmac::model('globals');
        $cityinfo = $globals_model->getCityinfo($cityid, 'c');
        $cityname = $cityinfo['CityName'];

        //取城市推荐热门酒店5个
        $city_hot_hotel = $this->common_model->getCityHotHotel($cityid, 5);
        //city经济型连锁酒店推荐
        $liansuo_array = $this->index_model->getIndexHotelArray($cityid, 'liansuo');
        //city最低价酒店
        $min_price_array = $this->index_model->getIndexHotelArray($cityid, 'min_price');
        //city豪华酒店推荐
        $haohua_array = $this->index_model->getIndexHotelArray($cityid, 'haohua');
        $rs = '<div class="tuijian_con">
                    <div class="tj_pic">
                        <ul>
              ';
        foreach ($city_hot_hotel AS $v) {
            $rs .= "<li><a href=\"index.php?m=hotelinfo&hotel_id={$v['hotel_id']}\" title=\"{$v['hotelname']}&#10;最低价格：{$v['min_price']}元起订 &#10;商圈：{$v['cbd_name']}\" target='_blank'><img src=\"{$picurl}{$v['picture']}\" width='120' height='90'/>";
            $rs .= Functions::cut_str($v['hotelname'], 9);
            $rs .= "</a></li>";
        }
        $rs .= '</ul></div>';

        $rs .= '<div class="tj_box">
                <h3><a href="index.php?m=liansuohotel&cityid=' . $cityid . '" target="_blank">' . $cityname . '经济型连锁酒店推荐</a></h3>
                <ul>';
        foreach ($liansuo_array AS $v) {
            $rs .= "<li><span class='pr'>￥{$v['min_price']}</span><span class='area'>品牌:<a href=\"index.php?m=hotellist&cityid={$v['cityid']}&chain_id={$v['chain_id']}\" title=\"{$cityname}{$v['chain_name']}\" target='_blank'>{$v['chain_name']}</a></span><a href=\"index.php?m=hotelinfo&hotel_id={$v['hotel_id']}\" title=\"{$v['hotelname']}&#10;最低价格：{$v['min_price']}元起订 &#10;商圈：{$v['cbd_name']}\" target='_blank'>{$v['hotelname']}</a></li>";
        }
        $rs .= '</ul></div>';

        $rs .= "<div class='tj_box'>
                <h3><a href=\"index.php?m=hotellist&cityid=$cityid&px=2\" target='_blank'>{$cityname}最低价酒店</a></h3>
                <ul>";
        foreach ($min_price_array AS $v) {
            $rs .= "<li><span class='pr'>￥{$v['min_price']}</span><span class='area'>位于:<a href=\"index.php?m=hotellist&cityid={$v['cityid']}&cbd_id={$v['cbd_id']}\" title=\"{$v['cbd_name']}\" target='_blank'>{$v['cbd_name']}</a></span><a href=\"index.php?m=hotelinfo&hotel_id={$v['hotel_id']}\" title=\"{$v['hotelname']}&#10;最低价格：{$v['min_price']}元起订 &#10;商圈：{$v['cbd_name']}\" target='_blank'>{$v['hotelname']}</a></li>";
        }
        $rs .= '</ul></div>';

        $rs .= "<div class='tj_box'>
                <h3><a href=\"index.php?m=hotellist&cityid=$cityid&px=3\" target='_blank'>{$cityname}豪华酒店推荐</a></h3>
                <ul>";
        foreach ($haohua_array AS $v) {
            $rs .= "<li><span class='pr'>￥{$v['min_price']}</span><span class='area'>位于:<a href=\"index.php?m=hotellist&cityid={$v['cityid']}&cbd_id={$v['cbd_id']}\" title=\"{$v['cbd_name']}\" target='_blank'>{$v['cbd_name']}</a></span><a href=\"index.php?m=hotelinfo&hotel_id={$v['hotel_id']}\" title=\"{$v['hotelname']}&#10;最低价格：{$v['min_price']}元起订 &#10;商圈：{$v['cbd_name']}\" target='_blank'>{$v['hotelname']}</a></li>";
        }
        $rs .= '</ul></div>';
        $rs .= '</div>';
        echo $rs;
        Functions::replace_for_mod_rewrite();
    }

}